import { Injectable } from '@nestjs/common';
import {RoleEntity} from './role.entity'
import {InjectRepository} from '@nestjs/typeorm'
import {Repository} from 'typeorm'
@Injectable()
export class RoleService {
  constructor(
    @InjectRepository(RoleEntity)
    private readonly roleRepository:Repository<RoleEntity>
  ){}

  async add(data:any){
   await this.roleRepository.save(data)
   return '添加角色成功'
  }

  async delete(data:any){
    const {id} = data
    const result = await this.roleRepository.findOne(id)
    await this.roleRepository.remove(result)
    return '删除角色成功'
  }
}
